from django.apps import AppConfig
from .model_loader import preload_models


class CoreConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "core"
    verbose_name = "核心模块"

    def ready(self):
        """Django启动时自动执行"""
        # 避免开发服务器重载时重复加载
        if not self.is_development_server():
            preload_models()

    @staticmethod
    def is_development_server():
        """检查是否在开发服务器运行"""
        import sys
        return 'renserver' in sys.argv
